package com.prime.tutorial.moviestore.view.reports;

import com.prime.tutorial.moviestore.domain.Device;
import com.prime.tutorial.moviestore.service.reports.ReportsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import java.util.List;
/**
 * Provides the view level of the devicesWithErrorsInTheirStatus report.
 * @author vasylja
 */
@Component("devicesWithErrorsInTheirStatus")
@Scope("request")
public class DevicesWithErrorsInTheirStatusImpl {
    private ReportsService reportsService;
    private List<Device> listDevicesWithErrorsInTheirStatus;

    @Autowired
    public DevicesWithErrorsInTheirStatusImpl(ReportsService reportsService) {
        this.reportsService = reportsService;
        setListDevicesWithErrorsInTheirStatus(this.reportsService.getListDevicesWithErrorsInTheirStatusReport());
    }

    public List<Device> getListDevicesWithErrorsInTheirStatus() {
        return listDevicesWithErrorsInTheirStatus;
    }

    private void setListDevicesWithErrorsInTheirStatus(List<Device> listDevicesWithErrorsInTheirStatus) {
        this.listDevicesWithErrorsInTheirStatus = listDevicesWithErrorsInTheirStatus;
    }
}
